/**
 Copyright (c) 2020-2022 宁波哥爱帮科技有限公司
 */
package cn.grab.fispservice.util;

/**
 * @description ThreadLocal工具类
 * @author 16411
 * @date 2022/12/19 13:54
 */
public class ThreadLocalUtils {

  private static ThreadLocal<Long> threadLocal = new ThreadLocal<>();

  /** 存储用户id */
  public static void set(Long userId){
    threadLocal.set(userId);
  }

  /** 获取用户id */
  public static Long get(){
    Long userId = threadLocal.get();

    return userId;
  }

  /** 释放内存,避免造成内存泄漏 */
  public static void remove(){
    threadLocal.remove();
  }

}
